package com.bawei.park2211a.polling

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.bawei.base.mvvm.BaseActivity
import com.bawei.park2211a.R
import com.bawei.park2211a.adapter.PollingAdapter
import com.bawei.park2211a.databinding.ActivityPollingBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/polling/PollingActivity")
class PollingActivity : BaseActivity<ActivityPollingBinding,PollingViewModel>() {
   private lateinit var pollingAdapter: PollingAdapter
    override fun initView() {
        viewModel.pollingList()
        pollingAdapter= PollingAdapter()
        binding.pollingRec.adapter=pollingAdapter
        binding.pollingRec.layoutManager=LinearLayoutManager(this)
    }

    override fun initData() {
        viewModel.pollingSuccess.observe(this){
            pollingAdapter.data.clear()
            pollingAdapter.data.addAll(it)
            pollingAdapter.notifyDataSetChanged()
        }
    }
}